# https://hub.docker.com/r/bitnami/elasticsearch
FROM bitnami/elasticsearch:7.17.26-debian-12-r0

USER root
# 更新证书
RUN mkdir -p /var/lib/apt/lists/partial && \
    apt-get update && apt-get install -y ca-certificates && update-ca-certificates

# 使用阿里云镜像
RUN echo "deb https://mirrors.aliyun.com/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
    echo "deb https://mirrors.aliyun.com/debian bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
    echo "deb https://mirrors.aliyun.com/debian bookworm-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
    echo "deb https://mirrors.aliyun.com/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list

# 更新系统并安装常用软件
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        curl git unzip vim wget locales && \
    # 安装 Linux 内核，Elasticsearch 依赖 seccomp（Secure Computing Mode，安全计算模式）来 限制进程能执行的系统调用（syscalls），从而提高安全性和稳定性。
    # apt-get install -y --no-install-recommends linux-image-$(dpkg --print-architecture) && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# 设置系统语言为中文（启用 zh_CN.UTF-8）
RUN sed -i 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen && \
    locale-gen && \
    update-locale LANG=zh_CN.UTF-8

# 设置时区和终端环境
ENV LANG=zh_CN.UTF-8 \
    LANGUAGE=zh_CN:zh:en_US:en \
    LC_ALL=zh_CN.UTF-8 \
    TZ=Asia/Shanghai \
    DEBIAN_FRONTEND=noninteractive \
    TERM=xterm

RUN ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
    echo $TZ > /etc/timezone && \
    dpkg-reconfigure --frontend noninteractive tzdata

USER 1001

EXPOSE 9200 9300
